﻿
#region Using directives

using System;
using System.Collections;
using System.Collections.Specialized;


using System.Web.Configuration;
using System.Data;
using System.Data.Common;
using System.Configuration.Provider;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;

using Pharmacy.Entities;
using Pharmacy.Data;
using Pharmacy.Data.Bases;

#endregion

namespace Pharmacy.Data.SqlClient
{
	/// <summary>
	/// This class is the Sql implementation of the NetTiersProvider.
	/// </summary>
	public sealed class SqlNetTiersProvider : Pharmacy.Data.Bases.NetTiersProvider
	{
		private static object syncRoot = new Object();
		private string _applicationName;
        private string _connectionString;
        private bool _useStoredProcedure;
        string _providerInvariantName;
		
		/// <summary>
		/// Initializes a new instance of the <see cref="SqlNetTiersProvider"/> class.
		///</summary>
		public SqlNetTiersProvider()
		{	
		}		
		
		/// <summary>
        /// Initializes the provider.
        /// </summary>
        /// <param name="name">The friendly name of the provider.</param>
        /// <param name="config">A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.</param>
        /// <exception cref="T:System.ArgumentNullException">The name of the provider is null.</exception>
        /// <exception cref="T:System.InvalidOperationException">An attempt is made to call <see cref="M:System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection)"></see> on a provider after the provider has already been initialized.</exception>
        /// <exception cref="T:System.ArgumentException">The name of the provider has a length of zero.</exception>
		public override void Initialize(string name, NameValueCollection config)
        {
            // Verify that config isn't null
            if (config == null)
            {
                throw new ArgumentNullException("config");
            }

            // Assign the provider a default name if it doesn't have one
            if (String.IsNullOrEmpty(name))
            {
                name = "SqlNetTiersProvider";
            }

            // Add a default "description" attribute to config if the
            // attribute doesn't exist or is empty
            if (string.IsNullOrEmpty(config["description"]))
            {
                config.Remove("description");
                config.Add("description", "NetTiers Sql provider");
            }

            // Call the base class's Initialize method
            base.Initialize(name, config);

            // Initialize _applicationName
            _applicationName = config["applicationName"];

            if (string.IsNullOrEmpty(_applicationName))
            {
                _applicationName = "/";
            }
            config.Remove("applicationName");


            #region "Initialize UseStoredProcedure"
            string storedProcedure  = config["useStoredProcedure"];
           	if (string.IsNullOrEmpty(storedProcedure))
            {
                throw new ProviderException("Empty or missing useStoredProcedure");
            }
            this._useStoredProcedure = Convert.ToBoolean(config["useStoredProcedure"]);
            config.Remove("useStoredProcedure");
            #endregion

			#region ConnectionString

			// Initialize _connectionString
			_connectionString = config["connectionString"];
			config.Remove("connectionString");

			string connect = config["connectionStringName"];
			config.Remove("connectionStringName");

			if ( String.IsNullOrEmpty(_connectionString) )
			{
				if ( String.IsNullOrEmpty(connect) )
				{
					throw new ProviderException("Empty or missing connectionStringName");
				}

				if ( DataRepository.ConnectionStrings[connect] == null )
				{
					throw new ProviderException("Missing connection string");
				}

				_connectionString = DataRepository.ConnectionStrings[connect].ConnectionString;
			}

            if ( String.IsNullOrEmpty(_connectionString) )
            {
                throw new ProviderException("Empty connection string");
			}

			#endregion
            
             #region "_providerInvariantName"

            // initialize _providerInvariantName
            this._providerInvariantName = config["providerInvariantName"];

            if (String.IsNullOrEmpty(_providerInvariantName))
            {
                throw new ProviderException("Empty or missing providerInvariantName");
            }
            config.Remove("providerInvariantName");

            #endregion

        }
		
		/// <summary>
		/// Creates a new <see cref="TransactionManager"/> instance from the current datasource.
		/// </summary>
		/// <returns></returns>
		public override TransactionManager CreateTransaction()
		{
			return new TransactionManager(this._connectionString);
		}
		
		/// <summary>
		/// Gets a value indicating whether to use stored procedure or not.
		/// </summary>
		/// <value>
		/// 	<c>true</c> if this repository use stored procedures; otherwise, <c>false</c>.
		/// </value>
		public bool UseStoredProcedure
		{
			get {return this._useStoredProcedure;}
			set {this._useStoredProcedure = value;}
		}
		
		 /// <summary>
        /// Gets or sets the connection string.
        /// </summary>
        /// <value>The connection string.</value>
		public string ConnectionString
		{
			get {return this._connectionString;}
			set {this._connectionString = value;}
		}
		
		/// <summary>
	    /// Gets or sets the invariant provider name listed in the DbProviderFactories machine.config section.
	    /// </summary>
	    /// <value>The name of the provider invariant.</value>
	    public string ProviderInvariantName
	    {
	        get { return this._providerInvariantName; }
	        set { this._providerInvariantName = value; }
	    }		
		
		///<summary>
		/// Indicates if the current <see cref="NetTiersProvider"/> implementation supports Transacton.
		///</summary>
		public override bool IsTransactionSupported
		{
			get
			{
				return true;
			}
		}

		
		#region "GroupProvider"
			
		private SqlGroupProvider innerSqlGroupProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="Group"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override GroupProviderBase GroupProvider
		{
			get
			{
				if (innerSqlGroupProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlGroupProvider == null)
						{
							this.innerSqlGroupProvider = new SqlGroupProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlGroupProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlGroupProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlGroupProvider SqlGroupProvider
		{
			get {return GroupProvider as SqlGroupProvider;}
		}
		
		#endregion
		
		
		#region "ShelfProvider"
			
		private SqlShelfProvider innerSqlShelfProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="Shelf"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ShelfProviderBase ShelfProvider
		{
			get
			{
				if (innerSqlShelfProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlShelfProvider == null)
						{
							this.innerSqlShelfProvider = new SqlShelfProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlShelfProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlShelfProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlShelfProvider SqlShelfProvider
		{
			get {return ShelfProvider as SqlShelfProvider;}
		}
		
		#endregion
		
		
		#region "MarkUpTypeProvider"
			
		private SqlMarkUpTypeProvider innerSqlMarkUpTypeProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="MarkUpType"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override MarkUpTypeProviderBase MarkUpTypeProvider
		{
			get
			{
				if (innerSqlMarkUpTypeProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlMarkUpTypeProvider == null)
						{
							this.innerSqlMarkUpTypeProvider = new SqlMarkUpTypeProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlMarkUpTypeProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlMarkUpTypeProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlMarkUpTypeProvider SqlMarkUpTypeProvider
		{
			get {return MarkUpTypeProvider as SqlMarkUpTypeProvider;}
		}
		
		#endregion
		
		
		#region "WebUserProvider"
			
		private SqlWebUserProvider innerSqlWebUserProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="WebUser"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override WebUserProviderBase WebUserProvider
		{
			get
			{
				if (innerSqlWebUserProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlWebUserProvider == null)
						{
							this.innerSqlWebUserProvider = new SqlWebUserProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlWebUserProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlWebUserProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlWebUserProvider SqlWebUserProvider
		{
			get {return WebUserProvider as SqlWebUserProvider;}
		}
		
		#endregion
		
		
		#region "StockProvider"
			
		private SqlStockProvider innerSqlStockProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="Stock"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override StockProviderBase StockProvider
		{
			get
			{
				if (innerSqlStockProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlStockProvider == null)
						{
							this.innerSqlStockProvider = new SqlStockProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlStockProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlStockProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlStockProvider SqlStockProvider
		{
			get {return StockProvider as SqlStockProvider;}
		}
		
		#endregion
		
		
		#region "SupplierProvider"
			
		private SqlSupplierProvider innerSqlSupplierProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="Supplier"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override SupplierProviderBase SupplierProvider
		{
			get
			{
				if (innerSqlSupplierProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlSupplierProvider == null)
						{
							this.innerSqlSupplierProvider = new SqlSupplierProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlSupplierProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlSupplierProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlSupplierProvider SqlSupplierProvider
		{
			get {return SupplierProvider as SqlSupplierProvider;}
		}
		
		#endregion
		
		
		#region "UnitTableProvider"
			
		private SqlUnitTableProvider innerSqlUnitTableProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="UnitTable"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override UnitTableProviderBase UnitTableProvider
		{
			get
			{
				if (innerSqlUnitTableProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlUnitTableProvider == null)
						{
							this.innerSqlUnitTableProvider = new SqlUnitTableProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlUnitTableProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlUnitTableProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlUnitTableProvider SqlUnitTableProvider
		{
			get {return UnitTableProvider as SqlUnitTableProvider;}
		}
		
		#endregion
		
		
		#region "ClassificationProvider"
			
		private SqlClassificationProvider innerSqlClassificationProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="Classification"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ClassificationProviderBase ClassificationProvider
		{
			get
			{
				if (innerSqlClassificationProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlClassificationProvider == null)
						{
							this.innerSqlClassificationProvider = new SqlClassificationProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlClassificationProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlClassificationProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlClassificationProvider SqlClassificationProvider
		{
			get {return ClassificationProvider as SqlClassificationProvider;}
		}
		
		#endregion
		
		
		#region "PoProvider"
			
		private SqlPoProvider innerSqlPoProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="Po"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override PoProviderBase PoProvider
		{
			get
			{
				if (innerSqlPoProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlPoProvider == null)
						{
							this.innerSqlPoProvider = new SqlPoProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlPoProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlPoProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlPoProvider SqlPoProvider
		{
			get {return PoProvider as SqlPoProvider;}
		}
		
		#endregion
		
		
		#region "AdjustmentProvider"
			
		private SqlAdjustmentProvider innerSqlAdjustmentProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="Adjustment"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override AdjustmentProviderBase AdjustmentProvider
		{
			get
			{
				if (innerSqlAdjustmentProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlAdjustmentProvider == null)
						{
							this.innerSqlAdjustmentProvider = new SqlAdjustmentProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlAdjustmentProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlAdjustmentProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlAdjustmentProvider SqlAdjustmentProvider
		{
			get {return AdjustmentProvider as SqlAdjustmentProvider;}
		}
		
		#endregion
		
		
		#region "DrugDispoProvider"
			
		private SqlDrugDispoProvider innerSqlDrugDispoProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="DrugDispo"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override DrugDispoProviderBase DrugDispoProvider
		{
			get
			{
				if (innerSqlDrugDispoProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlDrugDispoProvider == null)
						{
							this.innerSqlDrugDispoProvider = new SqlDrugDispoProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlDrugDispoProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlDrugDispoProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlDrugDispoProvider SqlDrugDispoProvider
		{
			get {return DrugDispoProvider as SqlDrugDispoProvider;}
		}
		
		#endregion
		
		
		#region "StockOutProvider"
			
		private SqlStockOutProvider innerSqlStockOutProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="StockOut"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override StockOutProviderBase StockOutProvider
		{
			get
			{
				if (innerSqlStockOutProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlStockOutProvider == null)
						{
							this.innerSqlStockOutProvider = new SqlStockOutProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlStockOutProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlStockOutProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlStockOutProvider SqlStockOutProvider
		{
			get {return StockOutProvider as SqlStockOutProvider;}
		}
		
		#endregion
		
		
		#region "RequiredAdjustmentProvider"
			
		private SqlRequiredAdjustmentProvider innerSqlRequiredAdjustmentProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="RequiredAdjustment"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override RequiredAdjustmentProviderBase RequiredAdjustmentProvider
		{
			get
			{
				if (innerSqlRequiredAdjustmentProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlRequiredAdjustmentProvider == null)
						{
							this.innerSqlRequiredAdjustmentProvider = new SqlRequiredAdjustmentProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlRequiredAdjustmentProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlRequiredAdjustmentProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlRequiredAdjustmentProvider SqlRequiredAdjustmentProvider
		{
			get {return RequiredAdjustmentProvider as SqlRequiredAdjustmentProvider;}
		}
		
		#endregion
		
		
		#region "StockOutDetailsProvider"
			
		private SqlStockOutDetailsProvider innerSqlStockOutDetailsProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="StockOutDetails"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override StockOutDetailsProviderBase StockOutDetailsProvider
		{
			get
			{
				if (innerSqlStockOutDetailsProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlStockOutDetailsProvider == null)
						{
							this.innerSqlStockOutDetailsProvider = new SqlStockOutDetailsProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlStockOutDetailsProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlStockOutDetailsProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlStockOutDetailsProvider SqlStockOutDetailsProvider
		{
			get {return StockOutDetailsProvider as SqlStockOutDetailsProvider;}
		}
		
		#endregion
		
		
		#region "PrescriptionVoidProvider"
			
		private SqlPrescriptionVoidProvider innerSqlPrescriptionVoidProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="PrescriptionVoid"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override PrescriptionVoidProviderBase PrescriptionVoidProvider
		{
			get
			{
				if (innerSqlPrescriptionVoidProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlPrescriptionVoidProvider == null)
						{
							this.innerSqlPrescriptionVoidProvider = new SqlPrescriptionVoidProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlPrescriptionVoidProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlPrescriptionVoidProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlPrescriptionVoidProvider SqlPrescriptionVoidProvider
		{
			get {return PrescriptionVoidProvider as SqlPrescriptionVoidProvider;}
		}
		
		#endregion
		
		
		#region "GrnProvider"
			
		private SqlGrnProvider innerSqlGrnProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="Grn"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override GrnProviderBase GrnProvider
		{
			get
			{
				if (innerSqlGrnProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlGrnProvider == null)
						{
							this.innerSqlGrnProvider = new SqlGrnProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlGrnProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlGrnProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlGrnProvider SqlGrnProvider
		{
			get {return GrnProvider as SqlGrnProvider;}
		}
		
		#endregion
		
		
		#region "PrescriptionDetailProvider"
			
		private SqlPrescriptionDetailProvider innerSqlPrescriptionDetailProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="PrescriptionDetail"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override PrescriptionDetailProviderBase PrescriptionDetailProvider
		{
			get
			{
				if (innerSqlPrescriptionDetailProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlPrescriptionDetailProvider == null)
						{
							this.innerSqlPrescriptionDetailProvider = new SqlPrescriptionDetailProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlPrescriptionDetailProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlPrescriptionDetailProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlPrescriptionDetailProvider SqlPrescriptionDetailProvider
		{
			get {return PrescriptionDetailProvider as SqlPrescriptionDetailProvider;}
		}
		
		#endregion
		
		
		#region "GrnDetailsProvider"
			
		private SqlGrnDetailsProvider innerSqlGrnDetailsProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="GrnDetails"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override GrnDetailsProviderBase GrnDetailsProvider
		{
			get
			{
				if (innerSqlGrnDetailsProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlGrnDetailsProvider == null)
						{
							this.innerSqlGrnDetailsProvider = new SqlGrnDetailsProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlGrnDetailsProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlGrnDetailsProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlGrnDetailsProvider SqlGrnDetailsProvider
		{
			get {return GrnDetailsProvider as SqlGrnDetailsProvider;}
		}
		
		#endregion
		
		
		#region "DrugDiscountProvider"
			
		private SqlDrugDiscountProvider innerSqlDrugDiscountProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="DrugDiscount"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override DrugDiscountProviderBase DrugDiscountProvider
		{
			get
			{
				if (innerSqlDrugDiscountProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlDrugDiscountProvider == null)
						{
							this.innerSqlDrugDiscountProvider = new SqlDrugDiscountProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlDrugDiscountProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlDrugDiscountProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlDrugDiscountProvider SqlDrugDiscountProvider
		{
			get {return DrugDiscountProvider as SqlDrugDiscountProvider;}
		}
		
		#endregion
		
		
		#region "PrescriptionProvider"
			
		private SqlPrescriptionProvider innerSqlPrescriptionProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="Prescription"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override PrescriptionProviderBase PrescriptionProvider
		{
			get
			{
				if (innerSqlPrescriptionProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlPrescriptionProvider == null)
						{
							this.innerSqlPrescriptionProvider = new SqlPrescriptionProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlPrescriptionProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlPrescriptionProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlPrescriptionProvider SqlPrescriptionProvider
		{
			get {return PrescriptionProvider as SqlPrescriptionProvider;}
		}
		
		#endregion
		
		
		#region "GrnVoidProvider"
			
		private SqlGrnVoidProvider innerSqlGrnVoidProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="GrnVoid"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override GrnVoidProviderBase GrnVoidProvider
		{
			get
			{
				if (innerSqlGrnVoidProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlGrnVoidProvider == null)
						{
							this.innerSqlGrnVoidProvider = new SqlGrnVoidProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlGrnVoidProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlGrnVoidProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlGrnVoidProvider SqlGrnVoidProvider
		{
			get {return GrnVoidProvider as SqlGrnVoidProvider;}
		}
		
		#endregion
		
		
		#region "AdjustmentDetailsProvider"
			
		private SqlAdjustmentDetailsProvider innerSqlAdjustmentDetailsProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="AdjustmentDetails"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override AdjustmentDetailsProviderBase AdjustmentDetailsProvider
		{
			get
			{
				if (innerSqlAdjustmentDetailsProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlAdjustmentDetailsProvider == null)
						{
							this.innerSqlAdjustmentDetailsProvider = new SqlAdjustmentDetailsProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlAdjustmentDetailsProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlAdjustmentDetailsProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlAdjustmentDetailsProvider SqlAdjustmentDetailsProvider
		{
			get {return AdjustmentDetailsProvider as SqlAdjustmentDetailsProvider;}
		}
		
		#endregion
		
		
		#region "PoDetailsProvider"
			
		private SqlPoDetailsProvider innerSqlPoDetailsProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="PoDetails"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override PoDetailsProviderBase PoDetailsProvider
		{
			get
			{
				if (innerSqlPoDetailsProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlPoDetailsProvider == null)
						{
							this.innerSqlPoDetailsProvider = new SqlPoDetailsProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlPoDetailsProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlPoDetailsProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlPoDetailsProvider SqlPoDetailsProvider
		{
			get {return PoDetailsProvider as SqlPoDetailsProvider;}
		}
		
		#endregion
		
		
		
		#region "CmsPatientProvider"
		
		private SqlCmsPatientProvider innerSqlCmsPatientProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="CmsPatient"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override CmsPatientProviderBase CmsPatientProvider
		{
			get
			{
				if (innerSqlCmsPatientProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlCmsPatientProvider == null)
						{
							this.innerSqlCmsPatientProvider = new SqlCmsPatientProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlCmsPatientProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlCmsPatientProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlCmsPatientProvider SqlCmsPatientProvider
		{
			get {return CmsPatientProvider as SqlCmsPatientProvider;}
		}
		
		#endregion
		
		
		#region "DeliveryNoteDetailsProvider"
		
		private SqlDeliveryNoteDetailsProvider innerSqlDeliveryNoteDetailsProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="DeliveryNoteDetails"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override DeliveryNoteDetailsProviderBase DeliveryNoteDetailsProvider
		{
			get
			{
				if (innerSqlDeliveryNoteDetailsProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlDeliveryNoteDetailsProvider == null)
						{
							this.innerSqlDeliveryNoteDetailsProvider = new SqlDeliveryNoteDetailsProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlDeliveryNoteDetailsProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlDeliveryNoteDetailsProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlDeliveryNoteDetailsProvider SqlDeliveryNoteDetailsProvider
		{
			get {return DeliveryNoteDetailsProvider as SqlDeliveryNoteDetailsProvider;}
		}
		
		#endregion
		
		
		#region "DeliveryNoteHistoryProvider"
		
		private SqlDeliveryNoteHistoryProvider innerSqlDeliveryNoteHistoryProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="DeliveryNoteHistory"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override DeliveryNoteHistoryProviderBase DeliveryNoteHistoryProvider
		{
			get
			{
				if (innerSqlDeliveryNoteHistoryProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlDeliveryNoteHistoryProvider == null)
						{
							this.innerSqlDeliveryNoteHistoryProvider = new SqlDeliveryNoteHistoryProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlDeliveryNoteHistoryProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlDeliveryNoteHistoryProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlDeliveryNoteHistoryProvider SqlDeliveryNoteHistoryProvider
		{
			get {return DeliveryNoteHistoryProvider as SqlDeliveryNoteHistoryProvider;}
		}
		
		#endregion
		
		
		#region "GdProvider"
		
		private SqlGdProvider innerSqlGdProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="Gd"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override GdProviderBase GdProvider
		{
			get
			{
				if (innerSqlGdProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlGdProvider == null)
						{
							this.innerSqlGdProvider = new SqlGdProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlGdProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlGdProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlGdProvider SqlGdProvider
		{
			get {return GdProvider as SqlGdProvider;}
		}
		
		#endregion
		
		
		#region "ImportPoDetailsProvider"
		
		private SqlImportPoDetailsProvider innerSqlImportPoDetailsProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ImportPoDetails"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ImportPoDetailsProviderBase ImportPoDetailsProvider
		{
			get
			{
				if (innerSqlImportPoDetailsProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlImportPoDetailsProvider == null)
						{
							this.innerSqlImportPoDetailsProvider = new SqlImportPoDetailsProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlImportPoDetailsProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlImportPoDetailsProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlImportPoDetailsProvider SqlImportPoDetailsProvider
		{
			get {return ImportPoDetailsProvider as SqlImportPoDetailsProvider;}
		}
		
		#endregion
		
		
		#region "PdProvider"
		
		private SqlPdProvider innerSqlPdProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="Pd"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override PdProviderBase PdProvider
		{
			get
			{
				if (innerSqlPdProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlPdProvider == null)
						{
							this.innerSqlPdProvider = new SqlPdProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlPdProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlPdProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlPdProvider SqlPdProvider
		{
			get {return PdProvider as SqlPdProvider;}
		}
		
		#endregion
		
		
		#region "StockWarningProvider"
		
		private SqlStockWarningProvider innerSqlStockWarningProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="StockWarning"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override StockWarningProviderBase StockWarningProvider
		{
			get
			{
				if (innerSqlStockWarningProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlStockWarningProvider == null)
						{
							this.innerSqlStockWarningProvider = new SqlStockWarningProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlStockWarningProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlStockWarningProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlStockWarningProvider SqlStockWarningProvider
		{
			get {return StockWarningProvider as SqlStockWarningProvider;}
		}
		
		#endregion
		
		
		#region "ViewRequiredAdjustmentProvider"
		
		private SqlViewRequiredAdjustmentProvider innerSqlViewRequiredAdjustmentProvider;

		///<summary>
		/// This class is the Data Access Logic Component for the <see cref="ViewRequiredAdjustment"/> business entity.
		/// It exposes CRUD methods as well as selecting on index, foreign keys and custom stored procedures.
		///</summary>
		/// <value></value>
		public override ViewRequiredAdjustmentProviderBase ViewRequiredAdjustmentProvider
		{
			get
			{
				if (innerSqlViewRequiredAdjustmentProvider == null) 
				{
					lock (syncRoot) 
					{
						if (innerSqlViewRequiredAdjustmentProvider == null)
						{
							this.innerSqlViewRequiredAdjustmentProvider = new SqlViewRequiredAdjustmentProvider(_connectionString, _useStoredProcedure, _providerInvariantName);
						}
					}
				}
				return innerSqlViewRequiredAdjustmentProvider;
			}
		}
		
		/// <summary>
		/// Gets the current <see cref="SqlViewRequiredAdjustmentProvider"/>.
		/// </summary>
		/// <value></value>
		public SqlViewRequiredAdjustmentProvider SqlViewRequiredAdjustmentProvider
		{
			get {return ViewRequiredAdjustmentProvider as SqlViewRequiredAdjustmentProvider;}
		}
		
		#endregion
		
		
		#region "General data access methods"

		#region "ExecuteNonQuery"
		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(string storedProcedureName, params object[] parameterValues)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteNonQuery(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteNonQuery(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		public override void ExecuteNonQuery(DbCommand commandWrapper)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			database.ExecuteNonQuery(commandWrapper);	
			
		}

		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		public override void ExecuteNonQuery(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			database.ExecuteNonQuery(commandWrapper, transactionManager.TransactionObject);	
		}


		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(CommandType commandType, string commandText)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteNonQuery(commandType, commandText);	
		}
		/// <summary>
		/// Executes the non query.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override int ExecuteNonQuery(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteNonQuery(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#region "ExecuteDataReader"
		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(string storedProcedureName, params object[] parameterValues)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteReader(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			Database database = transactionManager.Database;
			return database.ExecuteReader(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(DbCommand commandWrapper)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteReader(commandWrapper);	
		}

		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			Database database = transactionManager.Database;
			return database.ExecuteReader(commandWrapper, transactionManager.TransactionObject);	
		}


		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(CommandType commandType, string commandText)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteReader(commandType, commandText);	
		}
		/// <summary>
		/// Executes the reader.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override IDataReader ExecuteReader(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteReader(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#region "ExecuteDataSet"
		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(string storedProcedureName, params object[] parameterValues)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteDataSet(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			Database database = transactionManager.Database;
			return database.ExecuteDataSet(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(DbCommand commandWrapper)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteDataSet(commandWrapper);	
		}

		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			Database database = transactionManager.Database;
			return database.ExecuteDataSet(commandWrapper, transactionManager.TransactionObject);	
		}


		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(CommandType commandType, string commandText)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteDataSet(commandType, commandText);	
		}
		/// <summary>
		/// Executes the data set.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override DataSet ExecuteDataSet(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteDataSet(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#region "ExecuteScalar"
		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override object ExecuteScalar(string storedProcedureName, params object[] parameterValues)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteScalar(storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="storedProcedureName">Name of the stored procedure.</param>
		/// <param name="parameterValues">The parameter values.</param>
		/// <returns></returns>
		public override object ExecuteScalar(TransactionManager transactionManager, string storedProcedureName, params object[] parameterValues)
		{
			Database database = transactionManager.Database;
			return database.ExecuteScalar(transactionManager.TransactionObject, storedProcedureName, parameterValues);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override object ExecuteScalar(DbCommand commandWrapper)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);			
			return database.ExecuteScalar(commandWrapper);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandWrapper">The command wrapper.</param>
		/// <returns></returns>
		public override object ExecuteScalar(TransactionManager transactionManager, DbCommand commandWrapper)
		{
			Database database = transactionManager.Database;
			return database.ExecuteScalar(commandWrapper, transactionManager.TransactionObject);	
		}

		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override object ExecuteScalar(CommandType commandType, string commandText)
		{
			SqlDatabase database = new SqlDatabase(this._connectionString);
			return database.ExecuteScalar(commandType, commandText);	
		}
		/// <summary>
		/// Executes the scalar.
		/// </summary>
		/// <param name="transactionManager">The transaction manager.</param>
		/// <param name="commandType">Type of the command.</param>
		/// <param name="commandText">The command text.</param>
		/// <returns></returns>
		public override object ExecuteScalar(TransactionManager transactionManager, CommandType commandType, string commandText)
		{
			Database database = transactionManager.Database;			
			return database.ExecuteScalar(transactionManager.TransactionObject , commandType, commandText);				
		}
		#endregion

		#endregion


	}
}
